<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>ES6继承</h2>
</body>
<script>
    //A和B类，B如何继承A?
    class Person {
        constructor(name='无名',age=0) {
        this.name=name;
        this.age=age;
    }

    play() {
            console.log(`${this.name}爱打游戏`)
        }
    }

    class Chinese extends  Person{
        constructor (name='子类无名') {
             super(name) 
         }

         drive() {
            console.log(`${this.name}喜欢开车`)
         }

    }

   
    //原型链继承
  // Chinese.prototype=new Person();

    const c1=new Chinese('gogo');
    c1.play()
    c1.drive()

</script>
</html>